﻿public class ListNode
{
      public int val;
      public ListNode next;
      public ListNode(int val = 0, ListNode next = null)
    {
        this.val = val;
        this.next = next;
           }
 }

public class Solution206
{
    public ListNode ReverseList(ListNode head)
    {


        ListNode dummyHead = new ListNode();
        ListNode cur = head;
        ListNode next = head;
        while (cur != null)
        {
            next = cur.next;
            cur.next = dummyHead.next;
            dummyHead.next = cur;


            cur = next;
          

        }
        return dummyHead.next;
    }
}

class Program206
{
    static void Main206(string[] args)
    {
        Solution206 solution = new Solution206();
        ListNode head= new ListNode(1);
        solution.ReverseList(head);

    }
}